package news

import (
	"github.com/astaxie/beego/orm"
	"time"
)

// Category 栏目分类
type Category struct {
	Id         int       `orm:"pk;auto"`
	Name       string    `orm:"size(64);description(分类名称)"`
	Desc       string    `orm:"size(255);description(描述)"`
	IsActive   int       `orm:"default(1);description(启用:1,停用:0)"`
	IsDelete   int       `orm:"default(0);description(删除:1,未删除:0)"`
	CreateTime time.Time `orm:"description(创建时间);type(datetime);auto_now"`
	News       []*News   `orm:"reverse(many)"` // 反向关系，没有外键
}

// News 新闻分类
type News struct {
	Id         int       `orm:"pk;auto"`
	Title      string    `orm:"size(64);description(新闻标题)"`
	Content    string    `orm:"size(255);description(新闻内容);type(text)"`
	IsActive   int       `orm:"default(1);description(启用:1,停用:0)"`
	IsDelete   int       `orm:"default(0);description(删除:1,未删除:0)"`
	Category   *Category `orm:"rel(fk)"` // 正向关系，有外键，外键在多多一方
	CreateTime time.Time `orm:"description(创建时间);type(datetime);auto_now"`
}

func (c *Category) TableName() string {
	return "sys_category"

}

func (n *News) TableName() string {
	return "sys_news"

}
func init() {
	orm.RegisterModel(new(Category), new(News))
}
